<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    36. Valid Sudoku
   </h1>
   <p>
    Determine if a&nbsp;9x9 Sudoku board&nbsp;is valid.&nbsp;Only the filled cells need to be validated&nbsp;
    <strong>
     according to the following rules
    </strong>
    :
   </p>
   <ol>
    <li>
     Each row&nbsp;must contain the&nbsp;digits&nbsp;
     <code>
      1-9
     </code>
     without repetition.
    </li>
    <li>
     Each column must contain the digits&nbsp;
     <code>
      1-9
     </code>
     &nbsp;without repetition.
    </li>
    <li>
     Each of the 9
     <code>
      3x3
     </code>
     sub-boxes of the grid must contain the digits&nbsp;
     <code>
      1-9
     </code>
     &nbsp;without repetition.
    </li>
   </ol>
   <p>
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Sudoku-by-L2G-20050714.svg/250px-Sudoku-by-L2G-20050714.svg.png" style="height:250px; width:250px">
    <br>
    <small>
     A partially filled sudoku which is valid.
    </small>
   </p>
   <p>
    The Sudoku board could be partially filled, where empty cells are filled with the character
    <code>
     '.'
    </code>
    .
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input:</strong>
[
  ["5","3",".",".","7",".",".",".","."],
  ["6",".",".","1","9","5",".",".","."],
  [".","9","8",".",".",".",".","6","."],
  ["8",".",".",".","6",".",".",".","3"],
  ["4",".",".","8",".","3",".",".","1"],
  ["7",".",".",".","2",".",".",".","6"],
  [".","6",".",".",".",".","2","8","."],
  [".",".",".","4","1","9",".",".","5"],
  [".",".",".",".","8",".",".","7","9"]
]
<strong>Output:</strong> true
</pre>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input:</strong>
[
&nbsp; ["8","3",".",".","7",".",".",".","."],
&nbsp; ["6",".",".","1","9","5",".",".","."],
&nbsp; [".","9","8",".",".",".",".","6","."],
&nbsp; ["8",".",".",".","6",".",".",".","3"],
&nbsp; ["4",".",".","8",".","3",".",".","1"],
&nbsp; ["7",".",".",".","2",".",".",".","6"],
&nbsp; [".","6",".",".",".",".","2","8","."],
&nbsp; [".",".",".","4","1","9",".",".","5"],
&nbsp; [".",".",".",".","8",".",".","7","9"]
]
<strong>Output:</strong> false
<strong>Explanation:</strong> Same as Example 1, except with the <strong>5</strong> in the top left corner being 
    modified to <strong>8</strong>. Since there are two 8's in the top left 3x3 sub-box, it is invalid.
</pre>
   <p>
    <strong>
     Note:
    </strong>
   </p>
   <ul>
    <li>
     A Sudoku board (partially filled) could be valid but is not necessarily solvable.
    </li>
    <li>
     Only the filled cells need to be validated according to the mentioned&nbsp;rules.
    </li>
    <li>
     The given board&nbsp;contain only digits
     <code>
      1-9
     </code>
     and the character
     <code>
      '.'
     </code>
     .
    </li>
    <li>
     The given board size is always
     <code>
      9x9
     </code>
     .
    </li>
   </ul>
  </div>
  <div>
   <h1 class="question_title">
    36. 有效的数独
   </h1>
   <p>
    判断一个&nbsp;9x9 的数独是否有效。只需要
    <strong>
     根据以下规则
    </strong>
    ，验证已经填入的数字是否有效即可。
   </p>
   <ol>
    <li>
     数字&nbsp;
     <code>
      1-9
     </code>
     &nbsp;在每一行只能出现一次。
    </li>
    <li>
     数字&nbsp;
     <code>
      1-9
     </code>
     &nbsp;在每一列只能出现一次。
    </li>
    <li>
     数字&nbsp;
     <code>
      1-9
     </code>
     &nbsp;在每一个以粗实线分隔的&nbsp;
     <code>
      3x3
     </code>
     &nbsp;宫内只能出现一次。
    </li>
   </ol>
   <p>
    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Sudoku-by-L2G-20050714.svg/250px-Sudoku-by-L2G-20050714.svg.png" style="height: 250px; width: 250px;">
   </p>
   <p>
    <small>
     上图是一个部分填充的有效的数独。
    </small>
   </p>
   <p>
    数独部分空格内已填入了数字，空白格用&nbsp;
    <code>
     '.'
    </code>
    &nbsp;表示。
   </p>
   <p>
    <strong>
     示例&nbsp;1:
    </strong>
   </p>
   <pre><strong>输入:</strong>
[
  ["5","3",".",".","7",".",".",".","."],
  ["6",".",".","1","9","5",".",".","."],
  [".","9","8",".",".",".",".","6","."],
  ["8",".",".",".","6",".",".",".","3"],
  ["4",".",".","8",".","3",".",".","1"],
  ["7",".",".",".","2",".",".",".","6"],
  [".","6",".",".",".",".","2","8","."],
  [".",".",".","4","1","9",".",".","5"],
  [".",".",".",".","8",".",".","7","9"]
]
<strong>输出:</strong> true
</pre>
   <p>
    <strong>
     示例&nbsp;2:
    </strong>
   </p>
   <pre><strong>输入:</strong>
[
&nbsp; ["8","3",".",".","7",".",".",".","."],
&nbsp; ["6",".",".","1","9","5",".",".","."],
&nbsp; [".","9","8",".",".",".",".","6","."],
&nbsp; ["8",".",".",".","6",".",".",".","3"],
&nbsp; ["4",".",".","8",".","3",".",".","1"],
&nbsp; ["7",".",".",".","2",".",".",".","6"],
&nbsp; [".","6",".",".",".",".","2","8","."],
&nbsp; [".",".",".","4","1","9",".",".","5"],
&nbsp; [".",".",".",".","8",".",".","7","9"]
]
<strong>输出:</strong> false
<strong>解释:</strong> 除了第一行的第一个数字从<strong> 5</strong> 改为 <strong>8 </strong>以外，空格内其他数字均与 示例1 相同。
     但由于位于左上角的 3x3 宫内有两个 8 存在, 因此这个数独是无效的。</pre>
   <p>
    <strong>
     说明:
    </strong>
   </p>
   <ul>
    <li>
     一个有效的数独（部分已被填充）不一定是可解的。
    </li>
    <li>
     只需要根据以上规则，验证已经填入的数字是否有效即可。
    </li>
    <li>
     给定数独序列只包含数字&nbsp;
     <code>
      1-9
     </code>
     &nbsp;和字符&nbsp;
     <code>
      '.'
     </code>
     &nbsp;。
    </li>
    <li>
     给定数独永远是&nbsp;
     <code>
      9x9
     </code>
     &nbsp;形式的。
    </li>
   </ul>
  </div>
 </body>
</html>